package com.movitech.mobile.cz.base.supplier.controller;


import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.movitech.mobile.cz.base.modules.controller.RestReturnResult;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.plugins.Page;
import com.movitech.mobile.cz.base.supplier.entity.SEvaluationPerformScores;
import com.movitech.mobile.cz.base.supplier.service.SEvaluationPerformScoresService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
/**
 * <p>
 * SEvaluationPerformScores 前端控制器
 * </p>
 *
 * @author Movitech Mobile
 * @since 2018-02-28
 */
@RestController
@RequestMapping("/v1/sEvaluationPerformScores")
@Api(value = "供方评估--履约评分基础操作接口", description = "供方评估--履约评分基础操作接口")
public class SEvaluationPerformScoresController {
    @Autowired
    @Qualifier("sEvaluationPerformScoresService")
    private SEvaluationPerformScoresService sEvaluationPerformScoresService;

    @GetMapping("/allList")
    @ApiOperation(
            value = "获取所有供方评估--履约评分接口",
            notes = "获取所有供方评估--履约评分接口",
            response = SEvaluationPerformScores.class
    )
    public RestReturnResult list() {
        RestReturnResult restReturnResult = RestReturnResult.success();
        Page<SEvaluationPerformScores> page = sEvaluationPerformScoresService.selectPage(new Page<SEvaluationPerformScores>());
        restReturnResult.setData(page);
        return restReturnResult;
    }

    @PostMapping("/searchList/{pageNumber}")
    @ApiOperation(
            value = "供方评估--履约评分列表查询接口",
            notes = "供方评估--履约评分列表查询接口",
            response = SEvaluationPerformScores.class
    )
    public RestReturnResult searchList(@RequestBody SEvaluationPerformScores sEvaluationPerformScores,
                @ApiParam(value = "分页页数")@PathVariable Integer pageNumber) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        Page<SEvaluationPerformScores> page = new Page<>();
        page.setCurrent(pageNumber);
        EntityWrapper wrapper = new EntityWrapper<>();
        wrapper.setEntity(sEvaluationPerformScores);
        page = sEvaluationPerformScoresService.selectPage(page,wrapper);
        restReturnResult.setData(page);
        return restReturnResult;
    }

    @GetMapping("/getSEvaluationPerformScores/{id}")
    @ApiOperation(
            value = "供方评估--履约评分对象ID获取接口",
            notes = "供方评估--履约评分对对象ID获取接口",
            response = SEvaluationPerformScores.class
    )
    public RestReturnResult addSEvaluationPerformScores(@PathVariable String id) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        SEvaluationPerformScores sEvaluationPerformScores = sEvaluationPerformScoresService.selectById(id);
        restReturnResult.setData(sEvaluationPerformScores);
        return restReturnResult;
    }

    @PostMapping("/add")
    @ApiOperation(
            value = "供方评估--履约评分添加接口",
            notes = "供方评估--履约评分添加接口",
            response = SEvaluationPerformScores.class
    )
    public RestReturnResult add(@RequestBody SEvaluationPerformScores sEvaluationPerformScores) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        sEvaluationPerformScoresService.insert(sEvaluationPerformScores);
        restReturnResult.setData(sEvaluationPerformScores);
        return restReturnResult;
    }

    @PutMapping("/update")
    @ApiOperation(
            value = "供方评估--履约评分更新接口",
            notes = "供方评估--履约评分更新接口",
            response = SEvaluationPerformScores.class
    )
    public RestReturnResult update(@RequestBody SEvaluationPerformScores sEvaluationPerformScores) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        sEvaluationPerformScoresService.updateById(sEvaluationPerformScores);
        restReturnResult.setData(sEvaluationPerformScores);
        return restReturnResult;
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation(
            value = "供方评估--履约评分通过ID删除接口",
            notes = "供方评估--履约评分通过ID删除接口",
            response = SEvaluationPerformScores.class
    )
    public RestReturnResult update(@PathVariable String id) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        sEvaluationPerformScoresService.deleteById(id);
        return restReturnResult;
    }


}

